/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package backingBean;

import entities.Message;
import java.util.List;
import javaServices.MessageManager;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import org.apache.ibatis.session.SqlSession;
import services.ConnexionBD;

/**
 *
 * @author ambaye
 */
@ManagedBean
@RequestScoped
public class Listemessages {

    List<Message> mesMessages;
    

    public List<Message> getMesMessages() {
        return mesMessages;
    }

    public void setMesMessages(List<Message> mesMessages) {
        this.mesMessages = mesMessages;
    }
    
    /**
     * Creates a new instance of listemessages
     */
    public Listemessages() {
    }
    
    @PostConstruct
    public void InitData(){   
       System.out.println("test1");
     mesMessages = MessageManager.AffichermesMessages();
  
    }
    
    public String afficherunmessage(int mes){
        
        String retour=null;
        List<Message> test;
         SqlSession session = ConnexionBD.getConnexion();
        mesMessages=MessageManager.afficherunmesage(mes);
    if(mesMessages!=null)
    {
      retour="login";
    }
    else
    {
        retour="index";
    }
    return  retour;
    }
   
    
}
